/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine - application
// Copyright (c) 2014.  All Rights Reserved
//
// File:		AEWindowManager.cpp
// Author:		Gianluca Belardelli
// Date:		27/09/2013
//
/////////////////////////////////////////////////////////////////////////
#include <AEEngine.h>
#include <application/AEWindowManager.h>

#if defined (AE_PLATFORM_WIN32)

#include "application/AEWindow_win32.h"
#include "application/AEInternal_win32.h"

#elif defined (AE_PLATFORM_ANDROID)

#include "application/AEWindow_android.h"
#include "application/AEInternal_android.h"

#endif

AEWindowManager::~AEWindowManager( void )
{
}

void AEWindowManager::Initialize( void )
{
}

IAEWindow *AEWindowManager::CreateNewWindow( const char *lpTitle, AEINT32 nXPos, AEINT32 nYPos, AEINT32 nWidth, AEINT32 nHeight, AEUINT32 uiFlags )
{
	return __AECreateWindow( lpTitle, nXPos, nYPos, nWidth, nHeight, uiFlags );
}

IAEWindow *AEWindowManager::CreateNewWindow( AEEngineConfig *lpConfig, AEUINT32 uiFlags )
{
	AEUINT32 xRes=AEngine::GetDefaultVideoConfig()->GetVideoMode().uiXRes;
	AEUINT32 yRes=AEngine::GetDefaultVideoConfig()->GetVideoMode().uiYRes;
	AEUINT32 xPos=0, yPos=0;
		
	if( !lpConfig->bRunInWindowMode )
	{
		uiFlags |= AEWindowFullscreen;
	}
	else
	{
		if( lpConfig->uiWindowWidth > 0 )
		{
			if( lpConfig->uiWindowWidth > xRes )
				lpConfig->uiWindowWidth = xRes;
				
			if( lpConfig->uiWindowHeight > yRes )
				lpConfig->uiWindowHeight = yRes;

			xPos = (xRes - lpConfig->uiWindowWidth) / 2;
			yPos = (yRes - lpConfig->uiWindowHeight) / 2;
		}
		else
		{
			lpConfig->uiWindowWidth = xRes;
			lpConfig->uiWindowHeight = yRes;
		}
	}

	return __AECreateWindow( lpConfig, xPos, yPos, uiFlags );
}

IAEWindow *AEWindowManager::CreateWindowFromExistingHandle( AEWINDOWHANDLE wndHandle )
{
	return __AECreateWindow( NULL, (AEINT32)wndHandle, 0, 0, 0, 0xFFFFFFFF );
}

IAEWindow *AEWindowManager::NewEmptyWindow( void )
{
	return NULL;
}

void AEWindowManager::AddWindow( IAEWindow *lpWindow )
{
}

void AEWindowManager::DestroyWindow( IAEWindow *lpWindow )
{
}

void AEWindowManager::DestroyAllWindows( void )
{
}

//bool DoStepOnSALMessageLoop();

IAEWindow *AEWindowManager::GetWindow( AEWINDOWHANDLE wndHandle ) const
{
	return NULL;
}

IAEWindow *AEWindowManager::GetWindow( const wchar_t *lpwcTitle ) const
{
	return NULL;
}

AEUINT32 AEWindowManager::WindowCount( void ) const
{
	return 0;
}
